package org.lvhengchang.schoolmanager.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.lvhengchang.schoolmanager.service.StudentService;
import org.lvhengchang.schoolmanager.service.impl.StudentServiceImpl;

/**
 * 学生删除操作处理类
 * @author LvHengchang
 *
 */
@WebServlet("/student/delete")
public class StudentDeleteServlet extends HttpServlet {

    private static final long serialVersionUID = 1L;
    private StudentService studentService = new StudentServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
    	String student_id =  (String) req.getParameter("student_id");
        String student_name =  (String) req.getParameter("student_name");

        try {
             studentService.deleteStudent(student_id);
             req.setAttribute("student_name", student_name);
             req.getRequestDispatcher("/student/student_delete_success.jsp").forward(req, resp);
             
        } catch (Exception e) {
            throw new ServletException(e);
        }
        


    }

}
